<template>
	<om-page :title="pageTitle" class="om-font-size">
		<view class="margin-top-xs">
			<view class="tip">系统检测到您目前在多个组织中任职，请从下拉框中选择一个您要登录的组织：</view>
			<uni-list>
				<uni-list-item v-for="(item,index) in orginList" :key="index" @click="chooseOrgin(item.orgId)">
					<view>{{ item.orgName }}</view>
				</uni-list-item>
			</uni-list>
		</view>
	</om-page>
</template>

<script>
	export default {
		data() {
			return {
				pageTitle: '选择要登录的组织',
				orginList: []
			};
		},
		methods: {
			chooseOrgin(id){
				let _that = this
				_that.om.request('loginCenter/chooseOrg',{
					orgId: id,
				}).then(res => {
					if(res.succeed){
						uni.switchTab({
							url: '/pages/main/main/main'
						});
					}else{
						_that.om.toast('注册失败，请检查注册信息是否正确！')
					}
				});
			},
			getOrginList(){
				let _that = this
				_that.om.request('orgInstPosUserOfficial/getOrgByUser').then(res => {
					_that.orginList = res
				});
			},
		},
		onLoad() {
			
		},
		onShow(){
			this.getOrginList()
		}
	};
</script>

<style lang="scss" scoped>
	.tip{
		padding: 5px 15px;
		border-bottom: 1px solid #c8c7cc;
	}
</style>
